# Virtual Router Simulator 
#
# Copyright (C) 2009-2010 VRSim Project
# Author: Choonho Son <choonho@kt.com>
# URL: <http://vrsim.googlecode.com>
# For license information, see LICENSE.TXT
#
import VRSim.Globals as globals
from VRSim.Node.CiscoDevices import CiscoDevices
from VRSim.Node.Domain import disk
from VRSim.Node.Interface import Interface

from VRSim.Utils import debug

class C7200Device(CiscoDevices):
    def __init__(self,  nodeid):
        CiscoDevices.__init__(self,  nodeid)
        
        self.maxSlot = 6
        self.slot = {
                     'slot 0': {"adapter": ["C7200-IO-2FE",  2], 
                                0 : Interface(0, 0,  model='cisco', adapter='C7200-IO-2FE',  enabled=True),
                                1 : Interface(0, 1,  model='cisco', adapter='C7200-IO-2FE',  enabled=True) }, 
                     'slot 1': {"adapter": ["PA-2FE-TX",  2], 
                                0 : Interface(1, 0,  model='cisco',  adapter = 'PA-2FE-TX',  enabled=True),  
                                1 : Interface(1,  1,  model='cisco',  adapter = 'PA-2FE-TX',  enabled=True), 
                                2 : Interface(1,  2,  model='cisco',  adapter = 'PA-2FE-TX'), 
                                3 : Interface(1,  3,  model='cisco',  adapter = 'PA-2FE-TX'), 
                                4 : Interface(1, 4,  model='cisco',  adapter = 'PA-2FE-TX'), 
                                5 : Interface(1,  5,  model='cisco',  adapter = 'PA-2FE-TX'), 
                                6 : Interface(1,  6,  model='cisco',  adapter = 'PA-2FE-TX'), 
                                7 : Interface(1,  7,  model='cisco',  adapter = 'PA-2FE-TX') },
                     'slot 2': {"adapter": ["PA-8E",  8], 
                                0 : Interface(2, 0,  model='cisco',  adapter = 'PA-8E'),  
                                1 : Interface(2,  1,  model='cisco',  adapter = 'PA-8E'), 
                                2 : Interface(2,  2,  model='cisco',  adapter = 'PA-8E'), 
                                3 : Interface(2,  3,  model='cisco',  adapter = 'PA-8E'), 
                                4 : Interface(2, 4,  model='cisco',  adapter = 'PA-8E'), 
                                5 : Interface(2,  5,  model='cisco',  adapter = 'PA-8E'), 
                                6 : Interface(2,  6,  model='cisco',  adapter = 'PA-8E'), 
                                7 : Interface(2,  7,  model='cisco',  adapter = 'PA-8E') },
                     'slot 3': {"adapter": ["PA-8E",  8], 
                                0 : Interface(3, 0,  model='cisco',  adapter = 'PA-8E'),  
                                1 : Interface(3,  1,  model='cisco',  adapter = 'PA-8E'), 
                                2 : Interface(3,  2,  model='cisco',  adapter = 'PA-8E'), 
                                3 : Interface(3,  3,  model='cisco',  adapter = 'PA-8E'), 
                                4 : Interface(3, 4,  model='cisco',  adapter = 'PA-8E'), 
                                5 : Interface(3,  5,  model='cisco',  adapter = 'PA-8E'), 
                                6 : Interface(3,  6,  model='cisco',  adapter = 'PA-8E'), 
                                7 : Interface(3,  7,  model='cisco',  adapter = 'PA-8E') },
                     'slot 4': {"adapter": ["PA-8E",  8], 
                                0 : Interface(4, 0,  model='cisco',  adapter = 'PA-8E'),  
                                1 : Interface(4,  1,  model='cisco',  adapter = 'PA-8E'), 
                                2 : Interface(4,  2,  model='cisco',  adapter = 'PA-8E'), 
                                3 : Interface(4,  3,  model='cisco',  adapter = 'PA-8E'), 
                                4 : Interface(4, 4,  model='cisco',  adapter = 'PA-8E'), 
                                5 : Interface(4,  5,  model='cisco',  adapter = 'PA-8E'), 
                                6 : Interface(4,  6,  model='cisco',  adapter = 'PA-8E'), 
                                7 : Interface(4,  7,  model='cisco',  adapter = 'PA-8E') },
                     'slot 5': {"adapter": ["PA-8E",  8], 
                                0 : Interface(5, 0,  model='cisco',  adapter = 'PA-8E'),  
                                1 : Interface(5,  1,  model='cisco',  adapter = 'PA-8E'), 
                                2 : Interface(5,  2,  model='cisco',  adapter = 'PA-8E'), 
                                3 : Interface(5,  3,  model='cisco',  adapter = 'PA-8E'), 
                                4 : Interface(5, 4,  model='cisco',  adapter = 'PA-8E'), 
                                5 : Interface(5,  5,  model='cisco',  adapter = 'PA-8E'), 
                                6 : Interface(5,  6,  model='cisco',  adapter = 'PA-8E'), 
                                7 : Interface(5,  7,  model='cisco',  adapter = 'PA-8E') },
                     'slot 6': {"adapter": ["PA-8E",  8], 
                                0 : Interface(6, 0,  model='cisco',  adapter = 'PA-8E'),  
                                1 : Interface(6,  1,  model='cisco',  adapter = 'PA-8E'), 
                                2 : Interface(6,  2,  model='cisco',  adapter = 'PA-8E'), 
                                3 : Interface(6,  3,  model='cisco',  adapter = 'PA-8E'), 
                                4 : Interface(6, 4,  model='cisco',  adapter = 'PA-8E'), 
                                5 : Interface(6,  5,  model='cisco',  adapter = 'PA-8E'), 
                                6 : Interface(6,  6,  model='cisco',  adapter = 'PA-8E'), 
                                7 : Interface(6,  7,  model='cisco',  adapter = 'PA-8E') },
                    }
        
    def getPossibleAdapter(self,  slot=0):
        """ return adapter and max interface
        return value is dictionary
        """
        debug(slot,  "CiscoDomain : getPossibleAdapter")
        if str(slot) == '0' or str(slot) == "slot 0":
            return {"C7200-IO-2FE" : 2,
                          "C7200-IO-GE-E" : 1 }
        else:
            return {"PA-GE" : 1, 
                        "PA-2FE-TX" : 2,
                          "PA-4E" : 4, 
                          "PA-8E" : 8 }
    
    def getAdapterFromBandwidth(self,  bandWidth):
        if bandWidth == "E":
            return ["PA-4E",  "PA-8E"]
        elif bandWidth == "FE":
            return ["C7200-IO-2FE",  "PA-2FE-TX"]
        elif bandWidth == "GE":
            return ["C7200-IO-GE-E",  "PA-GE"]
        else:
            return ["PA-8E"]
    
